package day.day01;

import java.util.Random;

public class feibo {
    public static void main(String[] args) {
        Random rand = new Random();
        int n = rand.nextInt(30);
        int c = 0;
        for (int i = 0; i < n; i++) {
            int fn = f(n);
            System.out.println("斐波那契第"+i+"个数的值是："+f(i));
            c = fn++;

        }
        System.out.println("数列前" + (n-1) + "项和是:" + c);

//        int n=10;
    }

    public static int f(int n) {
            if (n == 0)
                return 0;
            else if (n == 1)
                return 1;
            else
                return f(n - 1) + f(n - 2);

    }
}